﻿using System.Net;
using System.Net.Mail;
using good1.ApplicationServices.Interface;

namespace good1.ApplicationServices
{
    public class SmtpService : ISmtpService
    {
        const string SystemEmail = "sender@mygoodpoints.org";
        // You need to specify your gmail or googlemail email address and password
        const string SystemPassword = "NotTelling";
        private const string SmtpHost = "mail.mygoodpoints.org";

        public void SendSystemMessage(string toAddress, string toName, string subject, string body)
        {
            MailMessage oMail = new MailMessage();

            oMail.To.Add(new MailAddress(toAddress, toName));
            oMail.From = new MailAddress(SystemEmail);
            oMail.Subject = subject;
            oMail.IsBodyHtml = true;
            oMail.Body = body;
            SmtpClient smtp = new SmtpClient(SmtpHost)
            {
                Credentials = new NetworkCredential(SystemEmail, SystemPassword)
            };
            //  Smtp.EnableSsl = true;   current host: webhost4life does not accept secure connections.
            smtp.Send(oMail);

        }
    }
}